package programs.expression.implementedClasses;

import programs.expression.superClasses.BinaryDoubleExpression;
import programs.expression.superClasses.Expression;
import programs.expression.superClasses.ExpressionType;

public class Subtraction extends BinaryDoubleExpression {

	public Subtraction(Expression left, Expression right) {
		super(left, right);
	}

	@Override
	public Object getValue() {
		return ((Double) getSubExpressionAt(1).getValue()) - ((Double) getSubExpressionAt(2).getValue());
	}

	@Override
	public boolean isValidExpression() {
		return ( super.isValidExpression() 
				&& (getSubExpressionAt(1).getReturnType() == ExpressionType.DOUBLE)
				&& (getSubExpressionAt(2).getReturnType() == ExpressionType.DOUBLE) ); 
	}

}
